var a, t = require("../../../@babel/runtime/helpers/toConsumableArray"), e = require("../../../@babel/runtime/helpers/objectSpread2"), s = require("../../../@babel/runtime/helpers/defineProperty"), d = getApp();

Page({
    data: (a = {
        typeClass: "",
        type: "",
        url: "",
        sub_team_count: "",
        show: !1,
        reward_id: "",
        rankingList: []
    }, s(a, "rankingList", null), s(a, "otherJson", {}), s(a, "isLoadMore", !0), s(a, "page", 1), 
    s(a, "total_page", 0), a),
    onLoad: function(a) {
        a.type && this.setData({
            type: a.type
        }), a.id && this.setData({
            id: a.id
        }), this.init(), 1 == a.type ? (this.data.typeClass = "奖励", this.data.url = "plugin.task-package.frontend.daily.reward-record", 
        this.data.otherJson = {
            record_id: this.data.id
        }) : 2 == a.type ? (this.data.typeClass = "总贡献值", this.data.url = "plugin.task-package.frontend.active-value.get-list") : 3 == a.type ? (this.data.typeClass = "贡献值", 
        this.data.url = "plugin.task-package.frontend.record.contribution-value") : 4 == a.type ? (this.data.typeClass = "复活", 
        this.data.url = "plugin.task-package.frontend.recovery.recovery-list") : 5 == a.type ? (this.data.typeClass = "手续费", 
        this.data.url = "plugin.task-package.frontend.record.procedures-fee") : 6 == a.type ? (this.data.typeClass = "平台流水", 
        this.data.url = "plugin.task-package.frontend.record.platform-flow") : 7 == a.type ? (this.data.typeClass = "下级团队", 
        this.data.url = "plugin.task-package.frontend.index.sub-team") : 8 == a.type && (this.data.typeClass = "兑换", 
        this.data.url = "plugin.task-package.frontend.record.get-list"), wx.setNavigationBarTitle({
            title: "".concat(this.data.typeClass, "记录")
        }), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore && this.getMoreData();
    },
    onShareAppMessage: function() {},
    init: function() {
        this.setData({
            page: 1,
            isLoadMore: !0,
            total_page: 0
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, console.log(this.data.page, this.data.total_page), 
        !(this.data.page >= this.data.total_page)) {
            this.data.page = this.data.page + 1, this.setData({
                page: this.data.page
            });
            var s = e({
                page: this.data.page
            }, this.data.otherJson);
            d._getNetWork({
                url: d.getNetAddresss(this.data.url),
                data: s,
                success: function(e) {
                    var s = e.data;
                    if (1 == s.result) {
                        a.data.isLoadMore = !0;
                        var d = [];
                        4 == a.data.type ? (d = s.data.data, a.data.total_page = s.data.last_page, a.data.rankingList.data = [].concat(t(a.data.rankingList.data), t(d))) : 1 == a.data.type || 8 == a.data.type ? (d = s.data.data, 
                        a.data.total_page = s.data.last_page, a.data.rankingList = [].concat(t(a.data.rankingList), t(d))) : (d = s.data.list.data, 
                        a.data.total_page = s.data.list.last_page, a.data.rankingList.data = [].concat(t(a.data.rankingList.data), t(d))), 
                        a.setData({
                            total_page: a.data.total_page,
                            rankingList: a.data.rankingList
                        });
                    }
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    getData: function() {
        var a = this, t = e({
            page: this.data.page
        }, this.data.otherJson);
        d._getNetWork({
            url: d.getNetAddresss(this.data.url),
            data: t,
            success: function(t) {
                var e = t.data;
                1 == e.result && (console.log(e), 4 == a.data.type ? (a.data.rankingList = e.data, 
                a.data.total_page = e.data.last_page) : 1 == a.data.type || 8 == a.data.type ? (a.data.rankingList = e.data.data, 
                a.data.total_page = e.data.last_page) : (a.data.rankingList = e.data.list, a.data.total_page = e.data.last_page), 
                7 == a.data.type ? a.data.sub_team_count = e.data.sub_team_count : 2 == a.data.type ? a.data.sub_team_count = e.data.total_amount : 3 == a.data.type ? a.data.sub_team_count = e.data.total : 5 == a.data.type || 6 == a.data.type ? (a.data.sub_team_count = e.data.total, 
                6 == a.data.type && (a.data.show = e.data.show, a.setData({
                    usable_name: e.data.usable_name
                }))) : 8 == a.data.type && a.setData({
                    usable_name: e.data.usable_name
                }), a.setData({
                    rankingList: a.data.rankingList,
                    sub_team_count: a.data.sub_team_count,
                    show: a.data.show,
                    total_page: a.data.total_page
                }));
            },
            fail: function(a) {
                console.log(a);
            }
        });
    }
});